package handle

import (
	"StockSrv/common/global"
	"StockSrv/model"
	"StockSrv/proto"
	"context"
)

type StockServer struct {
}

// 新增库存
func (s StockServer) InsertStock(ctx context.Context, req *proto.StockRequest) (*proto.StockResponse, error) {
	//TODO implement me
	//设置库存， 如果我要更新库存
	var inv model.Stock
	inv.GoodId = req.GoodId
	inv.StockNum = req.StockNum
	global.DB.Save(&inv)
	return &proto.StockResponse{
		Code:   200,
		Msg:    "请求成功",
		Status: true,
	}, nil
}

// 操作库存
func (s StockServer) ConfirmStock(ctx context.Context, req *proto.StockLogRequest) (*proto.StockLogResponse, error) {
	//TODO implement me   更新
	//原始库存  根据商品ID进行查询

	//判断操作类型
	if req.CnnfirmType == 1 { //入库

	}
	return nil, nil
}
